
from eeprom import Programmer

from time import sleep

port = "COM18"

byte64 = b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f'

if __name__ == '__main__':
    eeprom = Programmer()
    if eeprom.connect(port):
        print("连接")
    else:
        print("未连接")
        exit(0)

    if eeprom.is_open:
        eeprom.sendcommand("p", 2732,0,0x3f)
        print(len(byte64))
        tmp = []
        for i in byte64:
            # eeprom.write(i.to_bytes(1,'little'))
            # eeprom.write(bytes(i))
            b = int(i).to_bytes(1,'little')
            eeprom.write(b)
            tmp.append(b)

        print(tmp)
        sleep(1)

        res = eeprom.read(64)
        if res:
            print(res)
            tmp = []
            for i in res:
                tmp.append("{}".format(i & 0xff))

            print(tmp)

        res = eeprom.readline()
        print(res)